import { IPSApplication } from '../app/ipsapplication';
import { IPSSysServiceAPI } from '../service/ipssys-service-api';
import { IPSSysTestModule } from './ipssys-test-module';
import { IPSSysTestPrj } from './ipssys-test-prj';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysTestPrjImpl extends PSModelObjectImpl implements IPSSysTestPrj {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psapplication: IPSApplication | null = null;

  getPSApplication(): IPSApplication | null {
    if (this.psapplication != null) return this.psapplication;
    const value = this.M.getPSApplication;
    if (value == null) {
      return null;
    }
    this.psapplication = this.getPSModel4('app.IPSApplication', value, 'getPSApplication') as IPSApplication;
    return this.psapplication;
  }

  get psApplication(): IPSApplication | null {
    return this.getPSApplication();
  }

  getPSApplicationMust(): IPSApplication {
    const value = this.getPSApplication();
    if (value == null) {
      throw new Error('未指定系统应用');
    }
    return value;
  }

  protected pssysserviceapi: IPSSysServiceAPI | null = null;

  getPSSysServiceAPI(): IPSSysServiceAPI | null {
    if (this.pssysserviceapi != null) return this.pssysserviceapi;
    const value = this.M.getPSSysServiceAPI;
    if (value == null) {
      return null;
    }
    this.pssysserviceapi = this.getPSModel4('service.IPSSysServiceAPI', value, 'getPSSysServiceAPI') as IPSSysServiceAPI;
    return this.pssysserviceapi;
  }

  get psSysServiceAPI(): IPSSysServiceAPI | null {
    return this.getPSSysServiceAPI();
  }

  getPSSysServiceAPIMust(): IPSSysServiceAPI {
    const value = this.getPSSysServiceAPI();
    if (value == null) {
      throw new Error('未指定系统服务接口');
    }
    return value;
  }

  protected pssystestmodules: IPSSysTestModule[] | null = null;

  getPSSysTestModules(): IPSSysTestModule[] | null {
    if (this.pssystestmodules == null) {
      this.pssystestmodules = this.fillChildListModel(this.M.getPSSysTestModules, 'testing.IPSSysTestModule') as IPSSysTestModule[];
    }
    return this.pssystestmodules;
  }

  get psSysTestModules(): IPSSysTestModule[] | null {
    return this.getPSSysTestModules();
  }

  findPSSysTestModule(objKey: any): IPSSysTestModule | null {
    return this.getPSModel5('testing.IPSSysTestModule', this.getPSSysTestModules(), objKey) as IPSSysTestModule;
  }

  get prjTag(): string {
    return this.M.prjTag;
  }

  get prjTag2(): string {
    return this.M.prjTag2;
  }

  get prjType(): 'SYSAPP' | 'SYSSERVICEAPI' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.prjType;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysTestPrjImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'testing.IPSSysTestPrj') return true;
    return super.instanceof(cls);
  }
}
